<!-- 导航 -->
<div class="top-nav">
    <nav class="navbar navbar-default">
        <div class="container">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
            </div>
            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                <ul class="nav navbar-nav navbar-left">
                    <li><a href="/index.html" >主页</a></li>
                    <li class="dropdown">
                        <a href="#" data-toggle="dropdown">分类&nbsp;<span class="caret"></span></a>
                        <ul class="dropdown-menu2">
                            <!--分类菜单-->
                        </ul>
                    </li>
                    <li><a href="/link.html">友情链接</a></li>
                    <li><a href="/blogTime.html">时光轴</a></li>
                    <li><a href="/about.html">关于</a></li>
                </ul>
                <div class="clearfix"></div>
            </div>
        </div>
    </nav>
</div>

<script>
    $(function () {
       initType();
    })
    /**
     * 加载分类信息
     */
    function initType() {
        $.ajax({
            type: 'POST',
            url: '/blog/queryBlogType',
            dataType: 'json',
            contentType: 'application/json; charset=UTF-8',// 解决415错误
            success: function (res) {
                if('200' == res.code) {
                    var typeHtml = '';
                    $.each(res.data,function (index,val) {
                        typeHtml += '<li><a href="index.html?typeId='+val.typeId+'">'+val.typeName+'</a></li>';
                    });
                    $('.dropdown-menu2').html(typeHtml);

                }
            },
            error: function() {
               // layer.alert()
            }
        });
    }
    //鼠标点击按钮进行搜索
    $('#blog-search').on('click',function () {
        var keyWords = $('#search').val();
        var pageConf = {};
        pageConf.keyWords = keyWords;
        pageConf.pageSize = 5;
        pageConf.currentPage = 1;
        initPage(pageConf);
    });
    //回车键进行搜索
    $('#search').bind('keypress',function (event) {
        if(event.keyCode == '13') {
            $('#blog-search').click();
        }
    });

</script>